<!doctype html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
promise_test(t => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.two_heart_rate);
    return window.navigator.bluetooth.requestDevice({
        filters: [{services: [generic_access.name]}]
    })
    .then(device => device.gatt.connect())
    .then(gattServer => {
        let descriptor1;
        return gattServer.getPrimaryService(generic_access.name)
        .then(service => service.getCharacteristic(device_name.name))
        .then(characteristic => characteristic.getDescriptor(number_of_digitals.name))
        .then(descriptor => descriptor1 = descriptor)
        .then(() => gattServer.disconnect())
        .then(() => gattServer.connect())
        .then(() => gattServer.getPrimaryService(generic_access.name))
        .then(service => service.getCharacteristic(device_name.name))
        .then(characteristic => characteristic.getDescriptor(number_of_digitals.name))
        .then(descriptor2 => [descriptor1, descriptor2])
    })
    .then(descriptors_array => {
        assert_not_equals(descriptors_array[0], descriptors_array[1]);
    });
}, 'Calls to getDescriptor after a disconnection should return a different object.');
</script>
